package com.jiaai.cloud.system.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.jiaai.cloud.base.exception.ServiceException;
import com.jiaai.cloud.base.page.FrontPage;
import com.jiaai.cloud.base.util.RestResultGenerator;
import com.jiaai.cloud.system.service.ITPayManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 * @title  ${}
 * @author 佳爱网络科技
 * @version V1.0
 * @since 2017-8-21
 */
@RestController
@RequestMapping("/api/manage/payManage")
public class TPayManageController {
    @Autowired
    private ITPayManageService itPayManageService;

    //查所有
    @RequestMapping(value ="/findByAll",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Object findByAll(FrontPage page) throws ServiceException {
        try {
            EntityWrapper wrapper=new EntityWrapper();
            return RestResultGenerator.genSuccessResult(itPayManageService.selectPage(page.getPagePlus(),wrapper));
        } catch (Exception e) {
            throw new ServiceException("查询失败", e.getMessage());
        }
    }


    //    删除
    @RequestMapping(value = "/deleteId/{id}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public Object deleteId(@PathVariable("id") Integer id) throws ServiceException {
        try {

            itPayManageService.deleteById(id);
            return RestResultGenerator.genSuccessResult();
        } catch (Exception e) {
            throw new ServiceException("删除失敗", e.getMessage());
        }
    }



}
